package com.ny.demo;

import java.io.*;

public class TestFile {
    public static void setDate(String filename,String date) throws IOException {
        FileWriter fileWriter=new FileWriter(filename);
        BufferedWriter bufferedWriter=new BufferedWriter(fileWriter);
        bufferedWriter.write(date);
        bufferedWriter.close();

    }
    public void getData(String filename)  {
        FileReader fileReader = null;
        try {
            fileReader = new FileReader(filename);
            BufferedReader reader = new BufferedReader(fileReader);
            String data;
            while((data = reader.readLine())!=null){
                System.out.println(data);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        finally {
            System.out.println("不管是否发生异常都会执行finally里边的代码");
        }
    }

    public void setData(String filename, String data) {

    }
}


